<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="../js/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
    <title>过滤器</title>
</head>
<body>
    <div id="root">
        <h2>显示格式化后的事件</h2>
        <h2>{{time}}</h2>
        <h2>{{time | dataFormater}}</h2>
    </div>
    <script>
        //全局注册的过滤器
        Vue.filter('dataFormater',function(value,str='yyyy-MM-dd'){
            console.log(value);
            return moment(value).format('yyyy-MM-DD');
        });
        new Vue({
            el:'#root',
            data:{
                time:Date.now()
            },
            methods: {
                /* timeFormat(){
                    return moment(this.time).format('yyyy-MM-DD');
                } */
            },
        })
    </script>
</body>
</html>